home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 6.7 KB | 265 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: OvalShp.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef BOUNDSHP_H
- #include "BoundShp.h"
- #endif
-
- #ifndef OVALSHP_H
- #include "OvalShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWLINK_H
- #include "DrawLink.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawshapes
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- FW_DEFINE_AUTO(COvalShape)
- FW_DEFINE_CLASS_M1(COvalShape, CBoundedShape)
-
- const FW_ClassTypeConstant LOvalShape = FW_TYPE_CONSTANT('s','h','o','v');
- FW_REGISTER_ARCHIVABLE_CLASS(LOvalShape, COvalShape, COvalShape::Read, 0, 0, CBaseShape::Write)
-
- //========================================================================================
- // class COvalShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // COvalShape::COvalShape
- //----------------------------------------------------------------------------------------
-
- COvalShape::COvalShape():
- CBoundedShape(kOvalShape, kFrameOnly)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::COvalShape
- //----------------------------------------------------------------------------------------
-
- COvalShape::COvalShape(FW_CReadableStream& archive) :
- CBoundedShape(archive)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::~COvalShape
- //----------------------------------------------------------------------------------------
-
- COvalShape::~COvalShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::OutlineShape
- //----------------------------------------------------------------------------------------
-
- void COvalShape::OutlineShape(FW_CGraphicContext& gc, const FW_CInk& ink, const FW_CStyle& style, const FW_CRect& rect)
- {
- FW_CRect bounds(rect);
- AdjustRectForPenSize(bounds, style.GetPenSize());
- FW_COvalShape::RenderOval(gc,
- bounds,
- FW_kFrame,
- ink, style);
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::RenderShape
- //----------------------------------------------------------------------------------------
-
- void COvalShape::RenderShape(Environment* ev, ODFacet* facet, FW_CGraphicContext& gc)
- {
- FW_CRect rect = GetRectGeometry();
- AdjustRectForPenSize(rect, GetPenSize());
-
- if (HasFillStyle())
- FW_COvalShape::RenderOval(gc, rect, FW_kFill, fFillInk, fFillStyle);
-
- if (HasFrameStyle())
- FW_COvalShape::RenderOval(gc, rect, FW_kFrame, fFrameInk, fFrameStyle);
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::HitTest
- //----------------------------------------------------------------------------------------
-
- FW_Boolean COvalShape::HitTest(Environment *ev, FW_CGraphicContext& gc, const FW_CMouseEvent& theMouseEvent) const
- {
- FW_CPoint mouse = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- ODFacet* facet = theMouseEvent.GetFacet(ev);
- FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
- frame->GetContentView(ev)->FrameToViewContent(ev, mouse);
-
- FW_CRect bounds = GetRectGeometry();
- AdjustRectForPenSize(bounds, GetPenSize());
-
- FW_COvalShape ovalShape(bounds, HasFillStyle() ? FW_kFill : FW_kFrame);
- return ovalShape.HitTest(gc, mouse, FW_IntToFixed(2));
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::GetClipRegion
- //----------------------------------------------------------------------------------------
-
- void COvalShape::GetClipRegion(Environment* ev, ODShape* clipRegion)
- {
- FW_CRect bounds = GetRectGeometry();
- AdjustRectForPenSize(bounds, GetPenSize());
-
- ODShape* ovalShape = ::FW_CreateOvalODShape(ev, bounds);
- clipRegion->CopyFrom(ev, ovalShape);
- ovalShape->Release(ev);
-
- if (FrameOnly())
- {
- bounds.Inset(GetPenSize(), GetPenSize());
- ovalShape = ::FW_CreateOvalODShape(ev, bounds);
- clipRegion->Subtract(ev, ovalShape);
- ovalShape->Release(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::CreateShapeOutline
- //----------------------------------------------------------------------------------------
-
- ODShape* COvalShape::CreateShapeOutline(Environment *ev)
- {
- FW_CRect bounds = GetRectGeometry();
- AdjustRectForPenSize(bounds, GetPenSize());
-
- ODShape *dragRgn = ::FW_CreateOvalODShape(ev, bounds); // We don't acquire it because we return it
-
- ::FW_OutlineODShape(ev, dragRgn, GetPenSize());
-
- return dragRgn;
- }
-
- //----------------------------------------------------------------------------------------
- // COvalShape::Read
- //----------------------------------------------------------------------------------------
-
- void* COvalShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
- {
- FW_UNUSED(type);
- return FW_NEW(COvalShape, (stream));
- }
-
-